﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CSMF.ValidateCode.lib;

namespace CSMF.ValidateCode
{
    public partial class ConfirmCode : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(ConfirmValidateCode(Request["guid"], Request["validateCode"]));
        }

        public bool ConfirmValidateCode(string guid, string validateCode)
        {
            bool result = false;
            var table = Utility.GetHashtable();
            CodeValue value = (CodeValue)table[guid];
            if (value != null)
            {
                if (string.Compare(value.Code, validateCode) == 0)
                {
                    result = true;
                }
                // 不管是否校验成功，都删掉该项。
                table.Remove(guid);
            }

            return result;
        }
    }
}